package com.spzx.cart.api.factory;

import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.domain.CartInfo;
import com.spzx.common.core.domain.R;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

public class RemoteCartFallbackFactory implements FallbackFactory<RemoteCartService> {

    @Override
    public RemoteCartService create(Throwable throwable) {
        return new RemoteCartService() {

            @Override
            public R<List<CartInfo>> getCartCheckedList(Long userId, String source) {
                return R.fail(throwable.getMessage());
            }


            @Override
            public R<Boolean> updateCartPrice(Long userId, String source) {
                return R.fail("更新购物车价格失败:" + throwable.getMessage());
            }


            @Override
            public R<Boolean> deleteCartCheckedList(Long userId, String source) {
                return R.fail("删除用户购物车选中数据失败:" + throwable.getMessage());
            }
        };
    }
}
